/********************************************************/
/*	Copyright (C) 2016 Gong Li Bin			*/
/*	Project:	GlbCloud			*/
/*	Author:		gong_libin			*/
/*	Date:		2012_01_10			*/
/*	File:		MrQueue.h			*/
/********************************************************/

#ifndef	_MRQUEUE_H
#define	_MRQUEUE_H

#include "MrGlobal.h"
#include <stdexcept>
#include <pthread.h>

#define	MR_QUEUE			50000000

class CMrQueue
{
public:
	CMrQueue();
	CMrQueue(bool bMulti);
	virtual ~CMrQueue();

	ULONG MrQueueGetTotal();
	void* MrQueueHasNext(void* pCur);
	int MrQueuePop(void *pData, UINT uiSize);
	int MrQueuePut(void *pData, UINT uiSize);
	int MrQueueGet(void *pData, UINT uiSize);

protected:
	bool m_bMulti;
	void* m_pHead;
	void* m_pTail;
	ULONG m_ulTotal;

	pthread_cond_t m_stCond;
	pthread_mutex_t m_stLock;

private:
	void MrQueueLock();
	void MrQueueUnlock();

};

#endif /* _MRQUEUE_H */
